package state;

public class SoldState implements State{

    GumballMachine gumballMachine;

    public SoldState(GumballMachine gumballMachine) {
        this.gumballMachine = gumballMachine;
    }

    @Override
    public void insertQuarter() {
        System.out.println("请稍后，你已经投过币了");
    }

    @Override
    public void ejectQuarter() {
        System.out.println("请稍后，你已经弹出过币了");
    }

    @Override
    public void turnCrank() {
        System.out.println("正在抽奖中");
    }

    @Override
    public void dispense() {
        gumballMachine.releaseBall();
        if (gumballMachine.getCount() > 0) {
            gumballMachine.setState(gumballMachine.getNoQuarterState());
        } else {
            System.out.println("奖品没了");
            gumballMachine.setState(gumballMachine.getSoldOutState());
        }

    }
}
